#ifndef __XDEBUG_H__
#define __XDEBUG_H__

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

int DebugInfo(int level, FILE *fd, int line, char *file, char *format, ...);

#ifdef DEBUG
    #define INFO(format, args...) \
    DebugInfo(4, stdout, __LINE__, __FILE__, format, ##args)

    #define WARNING(format, args...) \
    DebugInfo(3, stdout, __LINE__, __FILE__, format, ##args)

    #define ERROR(format, args...) \
    DebugInfo(2, stdout, __LINE__, __FILE__, format, ##args)

    #define FATALERROR(format, args...) \
    DebugInfo(1, stdout, __LINE__, __FILE__, format, ##args)
#else
    #define INFO(format, args...)
    #define WARNING(format, args...)
    #define ERROR(format, args...)
    #define FATALERROR(format, args...)
#endif

#endif

